<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.org/ui" xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
	<ui:composition template="template.xhtml">

		<ui:define name="title">mehmet emmy</ui:define>
		<ui:define name="body">

			<h:form id="urunAramaForm">
				<c:choose>
					<c:when test="${AygitBean.selectedAygitObject != null}">
						<c:choose>
							<c:when test="#{SirketprofilBean.selectedSirket != null}">
								<p:commandButton id="getAllListButton" value="Firma Seçimini Kaldır"
									actionListener="#{AygitBean.restart}"
									update=":urunAramaForm" />
								
								<p:commandButton id="urunListButton" value="Şirket Ürün Listesine Git"
									actionListener="#{AygitBean.deleteSelectedAygit}"
									update=":urunAramaForm" />	
							</c:when>
							<c:otherwise>
								<p:commandButton id="urunListButton" value="Ürün Listesine Git"
									actionListener="#{AygitBean.restart}"
									update=":urunAramaForm" />	
							</c:otherwise>
						</c:choose>
																
						<c:choose>					
						
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='TV'}">								
								<ui:include src="tvDetails.xhtml" />
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='BELLEK'}" >
								<ui:include src="bellekDetails.xhtml" />
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='BUZDOLABI'}">
								<ui:include src="buzdlbDetails.xhtml" />
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='KLIMA'}">
								<ui:include src="klimaDetails.xhtml" />
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObject.aygit.aygitTuru =='MP3IPOD'}">
								<ui:include src="mp3ipodDetails.xhtml" />
							</c:when>
							<c:when test="#{AygitBean.selectedAygitObjectt.aygit.aygitTuru =='TELEFON'}">
								<ui:include src="telDetails.xhtml" />
							</c:when>
							<c:otherwise>
								Hata oluştu
							</c:otherwise>
						</c:choose>		
									
					</c:when>
					<c:otherwise>

						<p:dataTable id="urunAramaTable" var="urun"
							value="#{AygitBean.aygitlar}" widgetVar="urunlerTable"
							resizableColumns="true"
							emptyMessage="No product found with given criteria"
							rowKey="#{urun.aygitid}"
							selection="#{AygitBean.selectedAygitObject}"
							selectionMode="single" paginator="true" rows="10" liveScroll="true">

							<p:ajax event="rowSelect" listener="#{AygitBean.getSelectedAygitResList}"
								update=":urunAramaForm" />
							
							<f:facet name="header">
								<c:if test="#{SirketprofilBean.selectedSirket != null}">
             						<p:commandButton id="iptalButon" value="Firma Seçimini Kaldır"
									action="#{AygitBean.restart}" icon="ui-icon-close"
									update=":urunAramaForm" />
								</c:if>
							</f:facet>
							
							<f:facet name="header">
								<p:outputPanel>
									<h:outputText value="Search all fields:" />
									<p:inputText id="globalFilter" onkeyup="urunlerTable.filter()"
										style="width:150px" />
								</p:outputPanel>
							</f:facet>

							<p:column id="sirketAdColumn"
								filterBy="#{urun.sirketprofil.firmaAd}" headerText="Firma Adı"
								footerText="startsWith">
								<h:outputText value="#{urun.sirketprofil.firmaAd}" />
							</p:column>

							<p:column id="aygitTuruColumn" filterBy="#{urun.aygit.aygitTuru}"
								headerText="Aygıt Türü" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.aygitTuru}" />
							</p:column>

							<p:column id="modelColumn" filterBy="#{urun.aygit.model}"
								headerText="Model" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.model}" />
							</p:column>

							<p:column id="markaColumn" filterBy="#{urun.aygit.marka}"
								headerText="Marka" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{urun.aygit.marka}" />
							</p:column>
							
						</p:dataTable>

					</c:otherwise>
				</c:choose>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>